package com.fdb.efp.nls.common.constant.yed;

import java.util.stream.Stream;

/**
 * 需求编号:
 * 问题编号:
 * 开发人员: caoxin
 * 创建日期:2019/7/17
 * 功能描述:插槽配置
 * 修改日期:2019/7/17
 * 修改描述:
 */
public enum YEDAdaptedSoltEnum {
    /** 用信插槽配置------------------------------------------- start */

    //优e贷授信插槽配置
    YED_CREDIT_CUS_CREATE("11110004", "yedCusService", "优e贷客户建档插槽", "yedCreditCusCreateService", "1", 1),
    YED_CREDIT_LOAN_LMT("11110004", "yedLmtService", "优e贷额度生成插槽", "yedCreditLmtService", "1", 2),

    //优e贷征信查询
    YED_CREDIT_ZX_RULE("11110004", "yedCreditZxAccess", "优e贷二代征信查询插槽服务", "YedZXRuleService", "1", 3),

    // todo 优e贷用信插槽配置
    YED_APPLY_APPROVE("11110004", "yedApplyAccess", "优e贷用信风控审批插槽服务", "yedApplyRiskApproveSoltService", "4", 1),
    YED_APPLY_SIGN_CONTRACT("11110004", "yedSignContract", "优e贷用信合同签订插槽服务", "yedSignContractService", "5", 1),
    YED_APPLY_LOAN_RELEASE("11110004", "yedLoanRelease", "优e贷用信放款插槽服务", "yedLoanReleaseService", "6", 1),
    /** 用信插槽配置 ------------------------------------------- end */


    /** 优e贷主动还款插槽配置------------------------------------------- start */
    PSD_REPAYMENT_APPLY("11110004", "yedRepaymentApply", "优e贷还款申请规则服务", "yedRepaymentApplyService", "7", 1);
    /** 优e贷主动还款插槽配置 ------------------------------------------- end */
    // 产品ID
    private String prdId;
    // 插槽代码
    private String soltCode;
    // 插槽名称
    private String soltName;
    // 插槽服务类
    private String soltService;
    // 插槽阶段类
    private String soltStage;
    // 插槽顺序
    private int soltOrder;

    public String getPrdId() {
        return prdId;
    }

    public String getSoltCode() {
        return soltCode;
    }

    public String getSoltName() {
        return soltName;
    }

    public String getSoltService() {
        return soltService;
    }

    public String getSoltStage() {
        return soltStage;
    }

    public int getSoltOrder() {
        return soltOrder;
    }


    private YEDAdaptedSoltEnum(String prdId, String soltCode, String soltName, String soltService, String soltStage, int soltOrder) {
        this.prdId = prdId;
        this.soltCode = soltCode;
        this.soltName = soltName;
        this.soltService = soltService;
        this.soltStage = soltStage;
        this.soltOrder = soltOrder;
    }
    public static YEDAdaptedSoltEnum parse(String prdId, String soltCode) {
        return Stream.of(YEDAdaptedSoltEnum.values()).filter(value -> value.prdId.equals(prdId) && value.soltCode.equals(soltCode))
                .findFirst().orElseThrow(RuntimeException::new);

    }

    public boolean validateSoltService(String soltName, String soltService, String soltStage, int soltOrder) {
        return this.soltName.equals(soltName) && this.soltService.equals(soltService) && this.soltStage.equals(soltStage) && this.soltOrder == soltOrder;
    }

}
